package com.hbx.residential_service.service.impl;

import com.github.pagehelper.PageHelper;
import com.hbx.residential_service.dao.HouseDao;
import com.hbx.residential_service.domain.House;
import com.hbx.residential_service.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class HouseServiceImpl implements HouseService {
    @Autowired
    private HouseDao houseDao;
    @Override
    public List<House> findAll(int page, int size) throws Exception{
        //System.out.println(houseDao.findAll());
        PageHelper.startPage(page,size);
        return houseDao.findAll();
    }

    @Override
    public void save(House house) {
        houseDao.save(house);
//        System.out.println();
    }

    @Override
    public void deleteHouse(int houseIds) throws Exception {

       houseDao.deleteHouse(houseIds);
        //System.out.println("00000000000000000aaa"+houseIds+"aaa00000000000000000000000000000000000000000000000000000000000000000000");
    }

    @Override
    public House findUpdHouseById(int houseId) {
        return houseDao.findUpdHouseById(houseId);
    }

    @Override
    public void UpdateById(House house) {
        houseDao.UpdateById(house);
    }

    @Override
    public List<House> fsByUsername(String content, int page, int size) {
        PageHelper.startPage(page,size);
        return houseDao.fsByUsername("%"+content+"%",page,size);//在sql语句中不能存在两个双引号，因此这里在传入dao的时候先添加
    }
}
